﻿@using Esb.Domain.DomainObjects
@model ServiceDo
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "服务处理";
}
@Html.Raw(ViewBag.Scripts)
<div style="background: #205081; color: #FFFFFF; padding: 5px;" class="Header">
    <h2 style="float: left; margin-left: 20px;">
        <span style="font-size: 20px; font-weight: bold;">[ ESB治理中心后台 ]</span>
    </h2>
    <div style="float: left; margin-top: 30px; margin-left: 50px;">
        <a href="../ManageService">服务管理</a> <a href="#" target="_blank">服务处理</a></div>
    <div style="clear: both;">
    </div>
</div>
<div style="border: 1px solid #cccccc; margin: 5px; background: #ebf2f9; padding: 5px;">
    服务Id：@Model.Id<br />
    服务应用Id：<input type="text" name="ApplicationId" value="@Model.ApplicationId"/><br />
    服务路由：<input type="text" name="ServiceRouteName" value="@Model.ServiceRouteName"/><br />
    服务描述：<input type="text" name="ServiceDescription" value="@Model.ServiceDescription"/><br />
    协议：<input type="text" name="Protocol" value="@Model.Protocol" />（例如:http）<br />
    平台：<input type="text" name="Platform" value="@Model.Platform" />（Java、Net）<br />
    架构：<input type="text" name="Architecture" value="@Model.Architecture" />（Rest、WS）<br />
    域名：<input type="text" name="DomainName" value="@Model.DomainName" />（例如:xxx.com）<br />
    服务环境：<br />
    <div style="border: 1px solid #ccc; margin: 5px; padding: 5px; width: 600px; background: #f0f0f0;">
        环境类型：<input type="text" name="Environments[0].EnvironmentType" value="@((ViewBag.Add || Model.Environments == null) ? "Dev" : Model.Environments[0].EnvironmentType.ToString())" />（Dev）<br />
        配置地址：<input type="text" style="width: 400px;" name="Environments[0].RawServiceUrl" value="@((ViewBag.Add || Model.Environments == null) ? "" : Model.Environments[0].RawServiceUrl)" /><br />
    </div>
    <div style="border: 1px solid #ccc; margin: 5px; padding: 5px; width: 600px; background: #f0f0f0;">
        环境类型：<input type="text" name="Environments[1].EnvironmentType" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 1) ? "Test" : Model.Environments[1].EnvironmentType.ToString())" />（Test）<br />
        配置地址：<input type="text" style="width: 400px;" name="Environments[1].RawServiceUrl" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 1) ? "" : Model.Environments[1].RawServiceUrl)" /><br />
    </div>
    <div style="border: 1px solid #ccc; margin: 5px; padding: 5px; width: 600px; background: #f0f0f0;">
        环境类型：<input type="text" name="Environments[2].EnvironmentType" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 2) ? "Uat" : Model.Environments[2].EnvironmentType.ToString())" />（Uat）<br />
        配置地址：<input type="text" style="width: 400px;" name="Environments[2].RawServiceUrl" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 2) ? "" : Model.Environments[2].RawServiceUrl)" /><br />
    </div>
    <div style="border: 1px solid #ccc; margin: 5px; padding: 5px; width: 600px; background: #f0f0f0;">
        环境类型：<input type="text" name="Environments[3].EnvironmentType" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 3) ? "Prd" : Model.Environments[3].EnvironmentType.ToString())" />（Prd）<br />
        配置地址：<input type="text" style="width: 400px;" name="Environments[3].RawServiceUrl" value="@((ViewBag.Add || Model.Environments == null || Model.Environments.Count <= 3) ? "" : Model.Environments[3].RawServiceUrl)" /><br />
    </div>
    服务消费应用号码：<input type="text" name="Consumers" value="@ViewBag.Consumers" />（以英文,分隔）<br />
    服务告警邮件地址：<input type="text" name="AlertMail" value="@Model.AlertMail" />（以英文;分隔）<br />
    服务告警异常次数：<input type="text" name="AlertThreshold" value="@Model.AlertThreshold" /><br />
    服务告警间隔：@Model.AlertInterval<br />
    <input type="button" value="新增服务" onclick="SubmitService('add');" @(ViewBag.Add ? "" : "disabled='disabled'") /><input type="button"
        value="修改服务" onclick="SubmitService('update')" @(ViewBag.Add ? "disabled='disabled'" : "") /><input type="button" value="删除服务"
            onclick="SubmitService('delete');" @(ViewBag.Add ? "disabled='disabled'" : "") />
    <input type="hidden" value="" id="SubmitType" name="SubmitType" />
    <script>
        function SubmitService(submitType) {
            $("#SubmitType").val(submitType);
            if (submitType != "add") {
                $("form")[0].action = "../Service/?id=" + @Model.Id;
            }
            $("form").submit();
        }
    </script>
    <input type="button" value="查询日志" onclick="SubmitService('log');"  @(ViewBag.Add ? "disabled='disabled'" : "") /><br />
</div>
<div style="border-top: 1px solid #cccccc; margin-top: 10px; line-height: 25px; padding: 5px;">
    服务变更日志查询结果：<br />
    @if (ViewBag.Logs != null)
    {
        foreach (OperationLogDo log in ViewBag.Logs as List<OperationLogDo>)
        {
        @(log.OperationTime.ToLocalTime() + " " + log.UserName + "对服务:" + log.ServiceName + "进行" + log.OperationType + "操作")<br />
        }
    }
</div>
